`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date:    11:02:11 03/30/2014 
// Design Name: 
// Module Name:    Control_Unit 
// Project Name: 
// Target Devices: 
// Tool versions: 
// Description: 
//
// Dependencies: 
//
// Revision: 
// Revision 0.01 - File Created
// Additional Comments: 
//
//////////////////////////////////////////////////////////////////////////////////
module Control_Unit(Jump,MemRead,MemToReg,MemWrite,ALU_Src,RegWrite,opcode);
input [4:0] opcode;
//output [4:0] ALU_Op;
output Jump,MemRead,MemToReg,MemWrite,ALU_Src,RegWrite;
////////////////////////////////////
//
// PARAMETERS for opcodes
//
////////////////////////////////////
parameter VID = 5'd0; //refresh video
parameter AUD = 5'd1; //play note
parameter POLL = 5'd2; //poll user
parameter SET = 5'd3; //set reg
parameter MOV = 5'd4; //Move reg
parameter LOAD = 5'd5; //Load from mem
parameter SAVE = 5'd6; //Save to mem
parameter ADD = 5'd7; //Add two regs
parameter SUB = 5'd8; //subtract two regs
parameter MUL = 5'd9; //multiply two regs
parameter XOR = 5'd10; //xor
parameter ADDI = 5'd11; //these are math on immediate values
parameter SUBI = 5'd12;
parameter MULI = 5'd13;
parameter EQ = 5'd14; // equality checks
parameter NEQ = 5'd15;
parameter GT = 5'd16; // greater than
parameter LT = 5'd17;
parameter GE = 5'd18; // greater than equal to
parameter LE = 5'd19;
parameter JUMP = 5'd20; //raw jump
parameter JT = 5'd21; //conditioned jumps
parameter JF = 5'd22;
/////////////////////////////////////
//
// hardware
//
/////////////////////////////////////

assign Jump = opcode == JUMP;
assign MemRead = opcode == LOAD;
assign MemToReg = opcode == LOAD;
assign MemWrite = opcode == SAVE;
assign ALU_Src = opcode == SET || opcode == ADDI || opcode == SUBI || opcode == MULI;
assign RegWrite = opcode == ADD || opcode == SUB || opcode == MUL || opcode == XOR || opcode == MOV || opcode == SET || opcode == LOAD || opcode == ADDI || opcode == SUBI || opcode == MULI;

endmodule
